<html>
<head><meta charset="utf-8"><title>Splitting traits in two without breaking things · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Splitting.20traits.20in.20two.20without.20breaking.20things.html">Splitting traits in two without breaking things</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208124116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Splitting%20traits%20in%20two%20without%20breaking%20things/near/208124116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Splitting.20traits.20in.20two.20without.20breaking.20things.html#208124116">(Aug 26 2020 at 17:44)</a>:</h4>
<p>Today's stream meeting is making me think that it might be cool to allow <code>trait Iterator { ... }</code> to turn into <code>trait Iterator: LendingIterator { ... }</code> somehow, rather than using blanket impls, if it could be done so that all the existing <code>impl Iterator for ... {</code>s that already exist continue to work.  That way all the existing combinators that are fine on lending iterators could just move down, and we wouldn't need another one for the same thing.</p>
<p>That would presumably mean letting overrides apply to more than just the specific mentioned trait, if there's a supertrait (subtrait?  I never remember what the direction here is).  We could talk about extra crate-based or privacy-based restrictions on that to avoid "fragile base class"-style problems...</p>
<p>(And a more "out there" proposal: we could even change <code>Option&lt;Self::Item&gt;</code> to be an associated type that defaults to that, which would let people make it <code>Result&lt;Self::Item, Error&gt;</code> if they wanted -- then the combinators would just work on <code>impl Try</code> instead of <code>Option</code> explicitly...)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>